//
// Created by abstergo on 24-10-30.
//
#include <math/math.h>

using namespace tbs::math;

char TenBaseContext::readByte(const char &v) const {
  return v + '0';
}

char TenBaseContext::readChar(const char &v, int &sign) const {
  switch (v) {
  case '+':sign = SIGN_POSITIVE;
	return 0;
  case '-':sign = SIGN_NEGATIVE;
	return 0;
  case '.':sign = SIGN_DECIMAL;
	return 0;
  default:
	if (v >= '0' && v <= '9') {
	  sign = SIGN_NUMBER;
	  return v - '0';
	} else {
	  sign = SIGN_ERROR;
	  return 0;
	}
  }
}

int TenBaseContext::getBase() const {
  return 10;
}

char BinaryContext::readByte(const char &v) const {
  return v + '0';
}

char BinaryContext::readChar(const char &v, int &sign) const {
  switch (v) {
  case '+':sign = SIGN_POSITIVE;
	return 0;
  case '-':sign = SIGN_NEGATIVE;
	return 0;
  case '.':sign = SIGN_DECIMAL;
	return 0;
  default:
	if (v >= '0' && v <= '1') {
	  sign = SIGN_NUMBER;
	  return v - '0';
	} else {
	  sign = SIGN_ERROR;
	  return 0;
	}

  }
}

int BinaryContext::getBase() const {
  return 2;
}
